package com.hooda.framework;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @author zhangzp
 * @version 1.0
 * @date 2021/9/15
 */
public class Handler {

    private Object target;

    private Method method;

    private Pattern pattern;

    private Map<String, Integer> paramIndexMapping;

    private List<String> usernames;

    public Handler(Object target, Method method, Pattern pattern, List<String> usernames) {
        this.target = target;
        this.method = method;
        this.pattern = pattern;
        this.usernames = usernames;
        this.paramIndexMapping = new HashMap<>();
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }

    public List<String> getUsernames() {
        return usernames;
    }

    public void setUsernames(List<String> usernames) {
        this.usernames = usernames;
    }

    public boolean containsUsername(String username) {
        return usernames.contains(username);
    }
}
